<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>转账</title>
    <link href="res/style.css" rel="stylesheet">
    <script src="js/axios.min.js"></script>
    <script src="js/vue.min.js"></script>
</head>
<body>
<div id="app" class="flex">
    <main>
        <header class="flex">
            <div>
                <h3>源辰银行</h3>
                <small>ycinfo bank</small>
            </div>
            <div id="contact">
                <div>客服电话: 8888</div>
                <div>网址: www.ycinfo.bank.com</div>
            </div>
        </header>
        <div class="msg">
            倒计时: <h2>32</h2> 秒
        </div>
        <div id="pane" class="flex">
            <div class="btns">
                <a class="hidden">占位</a>
                <a class="hidden">占位</a>
                <a class="hidden">占位</a>
            </div>
            <div id="info">
                <h2>转账服务</h2>
                <form action="main.html">
                    <input placeholder="转入账号" type="number" v-model="toAccount"><br>
                    <input placeholder="转入金额" type="number" v-model="money">
                </form>
            </div>
            <div class="btns">
                <a class="hidden">占位</a>
                <a class="hidden">占位</a>
                <a class="right" @click="transfer">确定</a>
                <a href="main.html" class="right" @click="back">返回</a>
            </div>
        </div>
    </main>>
</div>
</body>
</html>

<script>
    new Vue({
        el: "#app",
        data() {
            return {
                toAccount: "",
                money: ""
            }
        },
        methods: {
            transfer() {
                if (this.toAccount === "" || this.money === "") {
                    alert("请输入完整信息");
                    return;
                }
                let params = new URLSearchParams();
                params.append("toAccount", this.toAccount);
                params.append("money", this.money);
                axios.post("bank/transfer", params).then(res => {
                    if (res.data.code === 200) {
                        alert(res.data.msg);
                        setTimeout(() => {
                            this.back();
                        }, 1000)
                    } else {
                        alert(res.data.msg);
                    }
                }).catch(err => {
                    alert("系统错误，请联系管理员");
                })
            },
            back() {
                window.location.href = "main.html";
            },

        },
        mounted() {
            this.info();
        }
    })
</script>
